package yns.springcloud.oakwood.guide.errorhandler;

import java.io.IOException;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpRequest;
import org.springframework.http.client.ClientHttpResponse;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestClient.ResponseSpec.ErrorHandler;

import yns.springcloud.oakwood.guide.bean.User;

@Component
public class RestClientErrorHandler implements ErrorHandler {
	
	private final Logger logger = LoggerFactory.getLogger(this.getClass());
	
	public String restClientErrorHandler(String value) {
		
		String info = "restClientErrorHandler value : " + value;
		logger.info(info);
		
		return info;
	}
	
	public String restClient2ErrorHandler(String value) {
		
		String info = "restClient2ErrorHandler value : " + value;
		logger.info(info);
		
		return info;
	}
	
	public String restClient3ErrorHandler(User user) {
		
		String info = "restClient3ErrorHandler user : " + user;
		logger.info(info);
		
		return info;
	}
	
	public String restClient4ErrorHandler(User user) {
		
		String info = "restClient4ErrorHandler user : " + user;
		logger.info(info);
		
		return info;
	}

	@Override
	public void handle(HttpRequest request, ClientHttpResponse response) throws IOException {
		logger.info("handle request : " + request);
		logger.info("handle response : " + response);
	}
	
}
